import * as PIXI from 'pixi.js'
import { seriesModule } from '@/utils/bundle'
import { RANK, SERIES } from '@/config'
import useDiyStore from '@/store/modules/useDiyStore'
import { getPixiData, setPixi } from '@/store/modules/usePixiStore'
import param from '../param'
export default async () => {
  const diyStore = useDiyStore()
  const container = new PIXI.Container()
  await Promise.all(
    Object.entries(RANK).map(async ([rank]) => {
      const rankContainerData = getPixiData(param.value.rankKey[rank]) // 品阶数据
      await Promise.all(
        Object.entries(SERIES).map(async ([series]) => {
          const seriesContainerData = getPixiData(param.value.seriesKey[series]) // 系列数据
          const sprite = await seriesModule({ rank, series } as Wx.Card.Param)
          sprite.scale.set(0.52)
          sprite.position.set(-15.4, 39)
          sprite.visible = diyStore.creationData.rank === rank && diyStore.creationData.series === series
          rankContainerData['rightSeries_' + series] = sprite.uid
          seriesContainerData['rightSeries_' + rank] = sprite.uid
          setPixi(sprite.uid, sprite)
          container.addChild(sprite)
        }),
      )
    }),
  )
  return container
}
